package nl.sodeso.cubicex.command.storage;

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Map;

import org.cubictest.selenium.custom.IElementContext;

import com.thoughtworks.selenium.Selenium;

import nl.sodeso.cubicex.CubicExBaseTestCase;

/**
 * Replaces the <code>captureEntirePageScreenshotToString</code> command of SeleniumIDE
 * 
 * @author y.bittan
 * @since 0.0.4
 */
public class CaptureEntirePageScreenShotToString extends CubicExBaseTestCase {

	/**
	 * {@inheritDoc}
	 */
	public void executeTest(Map<String, String> arguments,
			IElementContext context, Selenium selenium) throws Exception {

			String _kwargs=getArgAsString("kwargs");
			String _file=getArgAsString("filename");

			String buff=selenium.captureEntirePageScreenshotToString(_kwargs);
			
			File f=new File(_file);
			DataOutputStream fic=new DataOutputStream(new FileOutputStream(f));
			fic.write(buff.getBytes());
			assertTrue(f.length()>0);
	}

}
